package com.zmj.sy.mom.srv.aps.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.zmj.sy.mom.srv.aps.bean.entity.lantekpre.LantekNestPart;
import com.zmj.sy.mom.srv.aps.bean.vo.report.ReportPrePartResVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface LantekNestPartMapper extends SyMapper<LantekNestPart> {

    @Select("SELECT o.mater_code AS constructCode, pp.processing_no AS packageCode, part.part_id AS plmId, part.part_name AS partName, part.quantity AS partCount, plate.texture AS texture, " +
            "part.thickness AS thickness, part.length AS partLength, part.width AS partWidth, part.rectangle_area AS rectangleArea, pp.component_id AS assPlmId, plate.png_url AS platePngUrl " +
            "FROM tb_third_lantek_nest_part part LEFT JOIN tb_third_lantek_push_plan pp ON part.nest_plan_id = pp.nest_plan_id AND part.pre_version = pp.pre_version LEFT JOIN tb_order o ON pp.order_id = o.id " +
            "LEFT JOIN tb_third_lantek_nest_plate plate ON part.nest_id = plate.nest_id AND part.pre_version = plate.pre_version LEFT JOIN tb_third_lantek_nest_nest nest ON part.nest_id = nest.nest_id " +
            "AND part.pre_version = nest.pre_version " +
            " ${ew.customSqlSegment} ")
    List<ReportPrePartResVo> preNestPart(@Param(Constants.WRAPPER) QueryWrapper<LantekNestPart> qw);

}
